<%--
/***********************************************
* 파일명 : attend.jsp
* 기  능 : 근태관리 메인 화면
* 최초 작성일 : 2008/01/15
* @author : Yang Chang Hwan
*************************************************/
--%>

<%@ page 	language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib 	prefix="s" 		uri="/struts-tags"%>
<%@page import="attend.com.CodeMetrix"%>
<%response.addHeader("X-UA-Compatible" , "IE=EmulateIE7"); %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">

<head>
<s:head theme="ajax" />
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" />
<meta http-equiv="Content-Type" 	content="text/html; charset=UTF-8" />
<meta http-equiv="pragma" 			content="no-cache" />
<meta http-equiv="cache-control" 	content="no-cache" />
<meta http-equiv="expires" 			content="0" />

<title>근태관리(사원)</title>
<script type="text/javascript">
<!--
		//체크한 값을 넘기기 위한 전역변수
	var args;
	
	function fnc_check(field) {
		
		args = new Array();	//배열생성
		
		if (!field) {
			alert("<s:text name="alert.message.notCheck"/>");
			return false;
		}

		//체크박스가 하나일 경우 처리하는 로직
		if (!field.length) {
			if (!field.checked) {
				alert("<s:text name="alert.message.requiedCheck"/>");
				field.focus();
				return false;
			} else {
				args.push(field.value);
				return true;
			}
		}

		
		
		var checkflag = false;	//check init
		
		//체크된것이 없을시에 알람 메시지 출력
		//alert(field.length);	//checkbox 갯수
		for(i = 0 ; i < field.length ; i++) {
			if (!field[i].checked) {
				continue;
			} else {
				checkflag = true;
				//alert(field[i].value)
				args.push(field[i].value);	//배열에 값을 넣는다.
			}
		}
		
		//체크되지 않았으면 메시지 출력
		if (!checkflag) {
			alert("<s:text name="alert.message.selectData"/>");
			return false;
		}

		return true;
	}

	//ajajx_list-checkbox-
	function fnc_selct_items() {
		var frm = document.form;
		var chk = document.getElementById("s_chk");
		//alert(chk);
	}
	
	
	//출근입력 창을 띄운다.
	function fnc_check_in() {

		var chk = document.frm.s_chk;

		if (chk == undefined) {
			alert("데이터가 없습니다.");
			return false;
		}

		if ( typeof chk.length == "undefined" ) {
			//alert("휴가입력시에만 체크된 사항이 반영됩니다.");
		} else {
			for ( var i = 0 ; i < chk.length ; i++) {
				
				if (chk[i].checked) {
					if (chk[i].value == document.getElementById("frm_yyyymmdd").value || chk[i].disabled) {
						continue;
					} else if (chk[i].checked) {
						
						alert("출근은 현재일만 등록됩니다.\n선택은 휴가입력에서만 사용됩니다.");
						return false;
					}
					break;
				}
			}
		}
		
		var msg = document.frm.chk_in_msg.value;
		
		if (msg.length != 0) {
			alert(msg);
			return false;
		}
		
		var form = document.frm;
		
		var x = fnc_center_x(350);
		var y = fnc_center_y(280);

		var url     =   "attend_open_p.action";                  //popup page
        var nm      =   "check_in_p";                    		//popup window name
        var attr    =   "width=350 , height=280 , top=" + y + " , left=" + x + " , status=no";   //window size
        
        //window.open(url , nm , attr);   //팝업창 열기
        
        window.open("" , nm , attr);   //팝업창 열기
        
        form.target = nm;
        form.action = url;
        form.submit();
        
        return false;
	}
	

	//퇴근입력 창을 띄운다.
	function fnc_check_out() {

		var chk = document.frm.s_chk;

		if ( typeof chk.length == undefined ) {
			//alert("휴가입력시에만 체크된 사항이 반영됩니다.");
		} else {
			for ( var i = 0 ; i < chk.length ; i++) {
				
				if (chk[i].checked) {
					if (chk[i].value == document.getElementById("frm_yyyymmdd").value || chk[i].disabled) {
						continue;
					} else if (chk[i].checked) {
						alert("퇴근은 현재일만 등록됩니다.\n선택은 휴가입력에서만 사용됩니다.");
						return false;
					}
					break;
				}
			}
		}

		var msg = document.frm.chk_out_msg.value;
		
		if (msg.length != 0) {
			alert(msg);
			return false;
		}
		
		var form = document.frm;
		
		var msg = document.frm.chk_in_msg.value;
		
		if (msg.length == 0) {
			alert("<s:text name="alert.message.checkInFirst" />");
			return false;
		}

		var x = fnc_center_x(350);
		var y = fnc_center_y(280);

		var url     =   "attend_close_p.action";            	//popup page
        var nm      =   "check_in_p";                    		//popup window name
        var attr    =   "width=350 , height=280 , top=" + y + " , left=" + x + " , status=no";   //window size
        
        //window.open(url , nm , attr);   //팝업창 열기
        
        window.open("" , nm , attr);   //팝업창 열기
        
        form.target = nm;
        form.action = url;
        form.submit();
        
        return false;
	}
	//휴가입력창을 띄운다.
	function fnc_vacation_in(field) {
	
		//휴가일 경우 여러개를 선택하여 입력 가능하게 함.
		if (!fnc_check(field)) {
			return false;
		}

		document.getElementById("vaca_yyyymmdd").value = args;

		//alert(document.getElementById("vaca_yyyymmdd").value)

		var x = fnc_center_x(350);
		var y = fnc_center_y(205);
		
		var url		=	"attend_vacation_p.action";
		var nm      =   "check_in_p";                    		//popup window name
		var attr    =   "width=350 , height=205 , top=" + y + " , left=" + x + " , status=no";   //window size

		//window.showModalDialog(url , args , "dialogWidth:350px; dialogHeight:205px; help:0");
		window.open("" , nm , attr );
		
		frm.target = nm;
        frm.action = url;
        frm.submit();

		return false;
	}
	
	//메인페이지 조회버튼
	function fnc_retrieve_attend() {
		call_dojo();
		return false;
	}
	
	//ajax로 조회리스트 호출.
    function call_dojo() {
        dojo.event.topic.publish("ajax_list");
    }

	//onload
    function fnc_alert_msg() {
		//FALSE VALIDATE
		if ("<s:property value="msg" />" == "<%= CodeMetrix.FAILE %>") {
			alert("<s:text name="alert.message.SystemError" />");	
		}
		//temp_pop();
	}

  	//휴가입력창을 띄운다.
	function temp_pop() {
	
		var x = fnc_center_x(600);
		var y = fnc_center_y(400);
		
		var url		=	"/temp_pop.jsp";
		var nm      =   "temp";                    		//popup window name
		var attr    =   "width=600 , height=400 , top=" + y + " , left=" + x + " , status=no";   //window size

		//window.showModalDialog(url , args , "dialogWidth:350px; dialogHeight:205px; help:0");
		window.open("" , nm , attr );
		
		frm.target = nm;
        frm.action = url;
        frm.submit();

		return false;
	}

  	//전체선택 /해제
	function fnc_selectALL( f ) {
		try
		{
			if ( f.selectALL.checked ) {
				//1 row
				if (f.s_chk.length == undefined) {
					
					if (!f.s_chk.disabled) {
						f.s_chk.checked = true;
					}
					return false;
				}
				
				for ( var i = 0 ; i < f.s_chk.length ; i++ ) {
					if (!f.s_chk[i].disabled) {
						f.s_chk[i].checked = true;
					}  
				}
			} else {

				//1 row
				if (f.s_chk.length == undefined) {
					
					if (!f.s_chk.disabled) {
						f.s_chk.checked = false;
					}
					return false;
				}
				
				for ( var i = 0 ; i < f.s_chk.length ; i++ ) {
					if (!f.s_chk[i].disabled) {
						f.s_chk[i].checked = false;
					}
				}
			}
		} 
		catch(exception) 
		{
			alert("체크할 데이타가 없습니다.");
		}
	}

  	//popup 정가운데 띄우기
	function fnc_center_x(w) {

       	var x;
       	
		x =  (screen.availWidth - w) / 2;

       	return x;
	}

  	//popup 정가운데 띄우기
	function fnc_center_y(h) {

       	var y;
       	
		y =  (screen.availHeight - h) / 2;

       	return y;
	}

  	//근태상세정보보기
	//function fnc_detail_info() {

  	//	var f = frm;

	//	var x = fnc_center_x(900);
	//	var y = fnc_center_y(600);

	//	var url     =   "attend_detail_pop.action";                  //popup page
	//	var nm      =   "pop";                    		//popup window name
	//	var attr    =   "width=900 , height=600 , top=" + y + " , left=" + x + " , scrollbars=yes , status=no";   //window size
        
        //window.open(url , nm , attr);   //팝업창 열기
        
	//	window.open(url , nm , attr);   //팝업창 열기
	//	mm.focus();
        
	//	return false;
	//}
//-->
</script>
</head>
<body onload="fnc_alert_msg()">
<!--------- Contants Range : STR--------------->
	<div class="fl_ri">
		<div id="contants_box">
			<div id="tit">  
				<span class="fl_ri tit_navi">Home &gt; <span class="f_b">근태등록</span><img src="/images/btl_navi.gif" class="img_tp" /></span>
				<div class="fl_le"><img src="/images/tit_menu01_img01.gif" /></div>
			</div>
		<s:form theme="simple"  name="frm" id="frm">
			<s:hidden value="msg" />
			<s:hidden name="yyyymmdd" /><!-- 기준일자  20090213 -->
			<!-- 데이터 체크 결과 및 업데이트 결과를 담고 있는 변수 -->
			<s:hidden name="chk_yyyymmdd" id="chk_yyyymmdd" />
			<!-- USER IP -->
			<input type="hidden" name="ip" id="ip" value="<%=request.getRemoteAddr() %>" />
			
			<s:hidden name="vaca_yyyymmdd" id="vaca_yyyymmdd" /><!-- s_chk 체크된 값을 담음. -->
			
			<s:hidden id="cur_page" name="cur_page"/><!-- 현 페이지 번호 -->
			<!----------Search_Box : STR ---------->
			<div id="search01">
				<div id="search_box01">
					<ul>
						<li class="txt">조회년도</li>
						<li class="input">
							<s:select name="syear" 	cssClass="combobox120se" 	list="listYear" listKey="year" listValue="yyyy" />
						</li>
						<li class="txt01">조회월</li>
						<li class="input">
							<s:select name="smonth" cssClass="combobox120se"  	list="listMonth" listKey="month" listValue="mm" />
						</li>
					</ul>
					<ul>
						<li class="txt">그룹</li>
						<li class="input"><s:textfield name="group_nm" readonly="true" cssClass="input_120se" /><s:hidden name="group_no" /></li>
						<li class="txt01">팀</li>
						<li class="input"><s:textfield name="team_nm" readonly="true" cssClass="input_120se" /><s:hidden name="team_no" /></li>
						<li class="txt01">성명</li>
						<li class="input"><s:textfield name="emp_nm"  readonly="true" cssClass="input_120se" /><s:hidden name="emp_no" /></li>
					</ul>
					<ul class="btn">
						<span class="fl_ri">
								<li><img src="/images/btn_search.gif" src="/images/btn_search03.gif" style="cursor: pointer;" onclick="return getList('search')" />&nbsp;&nbsp;</li>
								<li><s:submit type="image" onclick="return fnc_check_in()"						src="/images/btn_attend_in.gif" 	cssClass="img_tm" title="출근등록" value="출근등록" /></li>
								<li><s:submit type='image' onclick="return fnc_check_out()" 					src="/images/btn_leaving_in.gif" 	cssClass="img_tm" title="퇴근등록" value="퇴근등록" /></li>
								<li><s:submit type='image' onclick="return fnc_vacation_in(this.form.s_chk)" 	src="/images/btn_holidays_reply.gif"  cssClass="img_tm" title="휴가변경" value="휴가변경" /></li>
						</span>
					</ul>
				</div>
			</div>	
			
			<!----------Search_Box : ENd ---------->  
			<!-- ajax로 데이터를 조회해 온다. -->
			<s:url id="ajax_list"  action="ajajx_attend_list"/>
			<s:div id="itemAmtlistDiv" theme="ajax" executeScripts="true" showLoadingText="false" href="%{ajax_list}" listenTopics="ajax_list" formId="frm" />

		</s:form>
		</div>
	</div>
	
</body>

</html>